// components/GlobTabar/GlobTabar.js
// {
//     "pagePath": "pages/home/home",
//     "text": "推广",
//     "iconPath": "/assets/tabbar_img/tuiguang-weixuanzhong@2x.png",
//     "selectedIconPath": "/assets/tabbar_img/tuiguang-xuanzhong@2x.png"
// },
// '/pages/home/home',
Component({

    /**
     * 组件的属性列表
     */
    properties: {
        tabarindex: {
            type: String
        }
    },

    /**
     * 组件的初始数据
     */
    data: {
        pageslist: [
            '/pages/promotion/promotion',
            '/pages/orders/orders',
            "/pages/equipment/equipment",
            '/pages/user/user',
        ],
        proxy:null,
        //tabar格式
        "tabBar": {
            "custom": true,
            "selectedColor": "#FF8C00",
            "list": [{
                    "pagePath": "pages/promotion/promotion",
                    "text": "推广",
                    "iconPath": "/assets/tabbar_img/tuiguang-weixuanzhong@2x.png",
                    "selectedIconPath": "/assets/tabbar_img/tuiguang-xuanzhong@2x.png"
                },
                {
                    "pagePath": "pages/orders/orders",
                    "text": "订单",
                    "iconPath": "/assets/tabbar_img/dingdan-weixuanzhong@2x.png",
                    "selectedIconPath": "/assets/tabbar_img/dingdan-xuanzhong@2x.png"
                },
                {
                    "pagePath": "pages/equipment/equipment",
                    "text": "设备",
                    "iconPath": "/assets/tabbar_img/shebei-weixuanzhong@2x.png",
                    "selectedIconPath": "/assets/tabbar_img/shebei-xuanzhong@2x.png"
                },
                {
                    "pagePath": "pages/user/user",
                    "text": "我的",
                    "iconPath": "/assets/tabbar_img/wode-weixuanzhong@2x.png",
                    "selectedIconPath": "/assets/tabbar_img/wode-xuanzhong@2x.png"
                }
            ]
        },
    },
    lifetimes: {
        attached: function () {
            // 在组件实例进入页面节点树时执行
            console.log('组件实例化');
            // userinfo.proxy = 1
            if (wx.getStorageSync('userinfo')) {
                let obj = wx.getStorageSync('userinfo')
                let data = JSON.parse(obj)
                this.setData({
                    proxy:data.proxy
                })
        
            }

        },
        detached: function () {
            // 在组件实例被从页面节点树移除时执行
        },
    },

    /**
     * 组件的方法列表
     */
    methods: {
        tabartap(e) {
            console.log(e.currentTarget.dataset.index);
            //存储当前选中的 底部tabar index 
            // wx.setStorageSync('tabar_index', e.currentTarget.dataset.index)
            // if(){

            // }
            console.log(this.data.pageslist[e.currentTarget.dataset.index]);
            wx.switchTab({
                url: this.data.pageslist[e.currentTarget.dataset.index]
            })
        }
    }
})